package(
    default_visibility = ["//visibility:public"],
)

licenses(["notice"])  # Apache 2.0

load(
    "//mace:mace.bzl",
    "if_android",
    "if_android_armv7",
    "if_bfloat16_enabled",
    "if_fp16_enabled",
    "if_hexagon_enabled",
    "if_hta_enabled",
    "if_neon_enabled",
    "if_opencl_enabled",
    "if_quantize_enabled",
    "if_rpcmem_enabled",
)

cc_library(
    name = "mace_api_test_header",
    hdrs = [
        "mace/libmace/mace_api_test.h",
    ],
    copts = [
        "-Werror",
        "-Wextra",
        "-Wno-missing-field-initializers",
    ],
    strip_include_prefix = "",
)

cc_test(
    name = "mace_cc_test",
    testonly = 1,
    srcs = glob(
        [
            "mace/libmace/*.cc",
            "mace/ops/*.cc",
            "mace/port/*.cc",
            "mace/utils/*.cc",
        ],
        exclude = [
            "mace/ops/fixpoint_test.cc",
        ],
    ) + if_neon_enabled(glob(
        [
            "mace/ops/arm/fp32/*.cc",
        ],
    )) + if_quantize_enabled(glob(
        [
            "mace/ops/arm/q8/*.cc",
            "mace/ops/fixpoint_test.cc",
        ],
    )) + if_bfloat16_enabled(glob(
        [
            "mace/ops/arm/bf16/*.cc",
        ],
    )) + if_fp16_enabled(glob(
        [
            "mace/ops/arm/fp16/*.cc",
        ],
    )) + if_opencl_enabled(glob(
        [
            "mace/ops/opencl/*.cc",
        ],
    )) + if_hta_enabled(
        [
            "mace/core/runtime/hexagon/hta_transform_test.cc",
        ],
    ),
    copts = [
        "-Werror",
        "-Wextra",
        "-Wno-missing-field-initializers",
    ] + if_neon_enabled([
        "-DMACE_ENABLE_NEON",
    ]) + if_android_armv7([
        "-mfpu=neon-fp16",
        "-mfloat-abi=softfp",
    ]) + if_opencl_enabled([
        "-DMACE_ENABLE_OPENCL",
    ]) + if_quantize_enabled([
        "-DMACE_ENABLE_QUANTIZE",
    ]) + if_bfloat16_enabled([
        "-DMACE_ENABLE_BFLOAT16",
    ]) + if_fp16_enabled([
        "-DMACE_ENABLE_FP16",
        "-march=armv8.2-a+fp16",
    ]) + if_hexagon_enabled([
        "-DMACE_ENABLE_HEXAGON",
    ]) + if_hta_enabled([
        "-DMACE_ENABLE_HTA",
    ]) + if_rpcmem_enabled([
        "-DMACE_ENABLE_RPCMEM",
    ]),
    linkstatic = 1,
    deps = [
        ":mace_api_test_header",
        "//mace/ops",
        "//test/ccutils",
        "@gtest//:gtest_main",
    ],
)
